/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Codigo;

import java.awt.event.*;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/**
 *
 * @author kyerte
 */
public class FrmClientes extends javax.swing.JFrame {

    private ConsultaCliente consultaClientes;
    private List<Cliente> resultadosClientes;
    private int numeroClientes;
    private int indiceActual;
    private int idCliente;
    private int idUltimoRegistroCliente;
    private boolean nuevoCliente;
    private Cliente clienteActual;
    private ConsultaDatosFinancieros consultaDatosFinancieros;
    private List<DatosFinancieros> resultadosDatosFinancieros;
    private int numeroDatosFinancieros;
    private int indiceActualDatos;
    private DatosFinancieros datosFinancierosActual;
    private int idDatosFinancieros;

    /**
     * Creates new form FrmClientes
     */
    public FrmClientes() {
        this.setIconImage(new ImageIcon(getClass().getResource("/Imagenes/Clients.png")).getImage());
        initComponents();
        consultaClientes = new ConsultaCliente();
        consultaDatosFinancieros = new ConsultaDatosFinancieros();
        explorarClientes();
        explorarDatosFinancieros();

        txtTelCasa.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtTelCasa.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtTelCelular.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtTelCelular.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtTelTrabajo.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtTelTrabajo.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtDireccion.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtDireccion.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtColonia.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtColonia.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtNombre.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtNombre.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtNSS.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtNSS.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtBanco.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtBanco.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtFovisste.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtFovisste.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtCURP.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtCURP.getText().length() == 18) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });
        txtCorreo.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
                if (txtCorreo.getText().length() == 45) {
                    e.consume();
                }
            }

            @Override
            public void keyPressed(KeyEvent arg0) {
            }

            @Override
            public void keyReleased(KeyEvent arg0) {
            }
        });

    }

    private void explorarClientes() {
        resultadosClientes = consultaClientes.obtenerTodosLosClientes();
        numeroClientes = resultadosClientes.size();

        if (numeroClientes != 0) {
            indiceActual = 0;
            clienteActual = resultadosClientes.get(indiceActual);

            idCliente = clienteActual.obtenerIdCliente();
            txtNombre.setText(clienteActual.obtenerNombre());
            txtDireccion.setText(clienteActual.obtenerCalle());
            txtColonia.setText(clienteActual.obtenerColonia());
            txtTelCasa.setText(clienteActual.obtenerTelefonoCasa());
            txtTelCelular.setText(clienteActual.obtenerTelefonoCelular());
            txtTelTrabajo.setText(clienteActual.obtenerTelefonoTrabajo());
            cboCivil.setSelectedItem(clienteActual.obtenerSoltero());
            txtCURP.setText(clienteActual.obtenerCURP());
            txtCorreo.setText(clienteActual.obtenerEMail());
            txtFechaNacimiento.setDate(clienteActual.obtenerFechaNacimiento());
            txtLugarTrabajo.setText(clienteActual.obtenerLugarTrabajo());
            cboEstatus.setSelectedItem(clienteActual.obtenerEstatus());

            txtIndiceActual.setText("" + (indiceActual + 1));
            lblTotal.setText("" + numeroClientes);

        } else {
            cmdGuardar.setEnabled(false);
            cmdCancelar.setEnabled(false);
            cmdEliminar.setEnabled(false);
        }
    }

    private void explorarDatosFinancieros() {
        resultadosDatosFinancieros = consultaDatosFinancieros.obtenerTodosDatosFinancieros();
        numeroDatosFinancieros = resultadosDatosFinancieros.size();

        if (numeroDatosFinancieros != 0) {
            indiceActualDatos = 0;
            datosFinancierosActual = resultadosDatosFinancieros.get(indiceActualDatos);

            idDatosFinancieros = datosFinancierosActual.obtenerIdCliente();
            txtNSS.setText(datosFinancierosActual.obtenerNumeroSeguroSocial());
            txtBanco.setText(datosFinancierosActual.obtenerNumeroBanco());
            txtFovisste.setText(datosFinancierosActual.obtenerNumeroFovisste());
            txtPresupuesto.setText(String.valueOf(datosFinancierosActual.obtenerPresupuesto()));
            txtAlcance.setText(String.valueOf(datosFinancierosActual.obtenerAlcance()));

        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jCalendar1 = new com.toedter.calendar.JCalendar();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        lblDireccion = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        lblColonia = new javax.swing.JLabel();
        txtColonia = new javax.swing.JTextField();
        lblTelCasa = new javax.swing.JLabel();
        txtTelCasa = new javax.swing.JTextField();
        lblTelCelular = new javax.swing.JLabel();
        txtTelCelular = new javax.swing.JTextField();
        lblTelTrabajo = new javax.swing.JLabel();
        txtTelTrabajo = new javax.swing.JTextField();
        lblEdoCivil = new javax.swing.JLabel();
        cboCivil = new javax.swing.JComboBox();
        lblCorreo = new javax.swing.JLabel();
        txtCorreo = new javax.swing.JTextField();
        lblFechaNacimiento = new javax.swing.JLabel();
        lblCURP = new javax.swing.JLabel();
        txtCURP = new javax.swing.JTextField();
        lblLugarTrabajo = new javax.swing.JLabel();
        ScrollPane = new javax.swing.JScrollPane();
        txtLugarTrabajo = new javax.swing.JTextArea();
        txtFechaNacimiento = new com.toedter.calendar.JDateChooser();
        jSeparator1 = new javax.swing.JSeparator();
        cmdNuevo = new javax.swing.JButton();
        cmdGuardar = new javax.swing.JButton();
        cmdEliminar = new javax.swing.JButton();
        cmdCancelar = new javax.swing.JButton();
        cmdPrimero = new javax.swing.JButton();
        cmdAnterior = new javax.swing.JButton();
        txtIndiceActual = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        lblTotal = new javax.swing.JLabel();
        cmdSiguiente = new javax.swing.JButton();
        cmdUltimo = new javax.swing.JButton();
        cmdBuscar = new javax.swing.JButton();
        lblEstatus = new javax.swing.JLabel();
        cboEstatus = new javax.swing.JComboBox();
        txt = new javax.swing.JPanel();
        lblBanco = new javax.swing.JLabel();
        lblNSS = new javax.swing.JLabel();
        lblFovisste = new javax.swing.JLabel();
        txtNSS = new javax.swing.JTextField();
        txtBanco = new javax.swing.JTextField();
        txtFovisste = new javax.swing.JTextField();
        lblIngresoPromedio = new javax.swing.JLabel();
        txtPresupuesto = new javax.swing.JTextField();
        lblSimbolo = new javax.swing.JLabel();
        lblIngresoPromedio1 = new javax.swing.JLabel();
        lblSimbolo1 = new javax.swing.JLabel();
        txtAlcance = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Clientes");
        setResizable(false);

        jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        lblNombre.setText("Nombre");

        txtNombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNombreActionPerformed(evt);
            }
        });

        lblDireccion.setText("Dirección");

        lblColonia.setText("Colonia");

        lblTelCasa.setText("Tel. Casa");

        txtTelCasa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelCasaActionPerformed(evt);
            }
        });

        lblTelCelular.setText("Tel. Celular");

        lblTelTrabajo.setText("Tel. Trabajo");

        txtTelTrabajo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelTrabajoActionPerformed(evt);
            }
        });

        lblEdoCivil.setText("Edo. Civil");

        cboCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Soltero", "Casado", "Divorciado", "Viudo", "Ninguno" }));
        cboCivil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboCivilActionPerformed(evt);
            }
        });

        lblCorreo.setText("E-mail");

        lblFechaNacimiento.setText("Fecha de nacimiento");

        lblCURP.setText("C.U.R.P.");

        txtCURP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCURPActionPerformed(evt);
            }
        });

        lblLugarTrabajo.setText("Lugar de trabajo");

        txtLugarTrabajo.setColumns(20);
        txtLugarTrabajo.setRows(5);
        ScrollPane.setViewportView(txtLugarTrabajo);

        cmdNuevo.setFont(new java.awt.Font("Ubuntu", 2, 15)); // NOI18N
        cmdNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Nuevo.png"))); // NOI18N
        cmdNuevo.setMnemonic('n');
        cmdNuevo.setText("Nuevo");
        cmdNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdNuevoActionPerformed(evt);
            }
        });

        cmdGuardar.setFont(new java.awt.Font("Ubuntu", 2, 15)); // NOI18N
        cmdGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Guardar.png"))); // NOI18N
        cmdGuardar.setMnemonic('g');
        cmdGuardar.setText("Guardar");
        cmdGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdGuardarActionPerformed(evt);
            }
        });

        cmdEliminar.setFont(new java.awt.Font("Ubuntu", 2, 15)); // NOI18N
        cmdEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Borrar.png"))); // NOI18N
        cmdEliminar.setMnemonic('e');
        cmdEliminar.setText("Eliminar");
        cmdEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdEliminarActionPerformed(evt);
            }
        });

        cmdCancelar.setFont(new java.awt.Font("Ubuntu", 2, 15)); // NOI18N
        cmdCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Cancelar.png"))); // NOI18N
        cmdCancelar.setMnemonic('c');
        cmdCancelar.setText("Cancelar");
        cmdCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdCancelarActionPerformed(evt);
            }
        });

        cmdPrimero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/First.png"))); // NOI18N
        cmdPrimero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdPrimeroActionPerformed(evt);
            }
        });

        cmdAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Back.png"))); // NOI18N
        cmdAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAnteriorActionPerformed(evt);
            }
        });

        txtIndiceActual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtIndiceActualActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        jLabel1.setText("/");

        lblTotal.setFont(new java.awt.Font("Ubuntu", 0, 24)); // NOI18N
        lblTotal.setText("100");

        cmdSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Forward.png"))); // NOI18N
        cmdSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdSiguienteActionPerformed(evt);
            }
        });

        cmdUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Last.png"))); // NOI18N
        cmdUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdUltimoActionPerformed(evt);
            }
        });

        cmdBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Busca.png"))); // NOI18N
        cmdBuscar.setMnemonic('B');
        cmdBuscar.setText("Buscar");
        cmdBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdBuscarActionPerformed(evt);
            }
        });

        lblEstatus.setText("Estatus");

        cboEstatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Prospecto", "Potencial", "Comprador", "Ninguno" }));
        cboEstatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboEstatusActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator1)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(cmdNuevo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cmdGuardar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cmdEliminar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cmdCancelar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cmdPrimero)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmdAnterior)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtIndiceActual, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1)
                                .addGap(9, 9, 9)
                                .addComponent(lblTotal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmdSiguiente)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmdUltimo)
                                .addGap(12, 12, 12)))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTelTrabajo, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblNombre)
                                    .addComponent(lblDireccion)
                                    .addComponent(lblColonia)
                                    .addComponent(lblTelCasa)
                                    .addComponent(lblTelCelular)
                                    .addComponent(lblCURP)
                                    .addComponent(lblEstatus))
                                .addGap(2, 2, 2)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtNombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
                                    .addComponent(txtDireccion, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtColonia)
                                    .addComponent(txtTelCelular, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTelCasa, javax.swing.GroupLayout.Alignment.LEADING)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTelTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(cboEstatus, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(txtCURP, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblEdoCivil)
                                            .addComponent(lblCorreo))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cboCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(lblFechaNacimiento)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtFechaNacimiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(ScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblLugarTrabajo))
                                .addGap(114, 114, 114))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(cmdBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(169, 169, 169))))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblEdoCivil)
                        .addComponent(cboCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblNombre))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDireccion)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCorreo)
                    .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblColonia)
                        .addComponent(txtColonia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblFechaNacimiento))
                    .addComponent(txtFechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTelCasa)
                    .addComponent(txtTelCasa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblLugarTrabajo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtTelCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTelCelular))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtTelTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTelTrabajo)))
                    .addComponent(ScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtCURP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblCURP)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmdBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cboEstatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblEstatus))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(cmdSiguiente, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdAnterior, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cmdCancelar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(cmdUltimo, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtIndiceActual, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)
                        .addComponent(lblTotal)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Datos", jPanel1);

        lblBanco.setFont(new java.awt.Font("Ubuntu", 3, 18)); // NOI18N
        lblBanco.setText("Banco");

        lblNSS.setFont(new java.awt.Font("Ubuntu", 3, 18)); // NOI18N
        lblNSS.setText("Numero de seguridad social");

        lblFovisste.setFont(new java.awt.Font("Ubuntu", 3, 18)); // NOI18N
        lblFovisste.setText("FOVISSTE");

        txtNSS.setFont(new java.awt.Font("Ubuntu", 2, 18)); // NOI18N
        txtNSS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNSSActionPerformed(evt);
            }
        });

        txtBanco.setFont(new java.awt.Font("Ubuntu", 2, 18)); // NOI18N

        txtFovisste.setFont(new java.awt.Font("Ubuntu", 2, 18)); // NOI18N

        lblIngresoPromedio.setFont(new java.awt.Font("Ubuntu", 3, 18)); // NOI18N
        lblIngresoPromedio.setText("Ingreso promedio");

        txtPresupuesto.setFont(new java.awt.Font("Ubuntu", 2, 18)); // NOI18N
        txtPresupuesto.setText("0");

        lblSimbolo.setFont(new java.awt.Font("Ubuntu", 2, 14)); // NOI18N
        lblSimbolo.setText("$");

        lblIngresoPromedio1.setFont(new java.awt.Font("Ubuntu", 3, 18)); // NOI18N
        lblIngresoPromedio1.setText("Presupuesto");

        lblSimbolo1.setFont(new java.awt.Font("Ubuntu", 2, 14)); // NOI18N
        lblSimbolo1.setText("$");

        txtAlcance.setFont(new java.awt.Font("Ubuntu", 2, 18)); // NOI18N
        txtAlcance.setText("0");

        javax.swing.GroupLayout txtLayout = new javax.swing.GroupLayout(txt);
        txt.setLayout(txtLayout);
        txtLayout.setHorizontalGroup(
            txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(txtLayout.createSequentialGroup()
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, txtLayout.createSequentialGroup()
                        .addGap(189, 189, 189)
                        .addComponent(lblBanco, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(txtLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNSS, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblFovisste, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addGap(18, 18, 18)
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(txtBanco, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                        .addComponent(txtFovisste, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
                    .addComponent(txtNSS, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(txtLayout.createSequentialGroup()
                        .addComponent(lblIngresoPromedio, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblSimbolo))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, txtLayout.createSequentialGroup()
                        .addComponent(lblIngresoPromedio1)
                        .addGap(18, 18, 18)
                        .addComponent(lblSimbolo1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtAlcance)
                    .addComponent(txtPresupuesto, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        txtLayout.setVerticalGroup(
            txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(txtLayout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(txtLayout.createSequentialGroup()
                        .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblNSS, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNSS, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtBanco, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblBanco, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblIngresoPromedio1)
                            .addComponent(lblSimbolo1)
                            .addComponent(txtAlcance, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(txtLayout.createSequentialGroup()
                            .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblIngresoPromedio)
                                    .addComponent(lblSimbolo))
                                .addComponent(txtPresupuesto, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(53, 53, 53))))
                .addGap(21, 21, 21)
                .addGroup(txtLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFovisste, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtFovisste, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(294, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Datos financieros", txt);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cmdGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdGuardarActionPerformed

        cmdGuardar.setEnabled(true);
        cmdCancelar.setEnabled(true);

        int resultado = 0;
        int resultado2 = 0;
        String mensaje = "";
        String str = txtPresupuesto.getText();
        boolean valido = ValidaNumeros.validarNumeroDoble(str);
        str = txtAlcance.getText();
        boolean valido2 = ValidaNumeros.validarNumeroDoble(str);
        java.sql.Date fechaNac = new java.sql.Date(0);
        boolean fallo = false;

        try {
            System.out.println(txtFechaNacimiento.getDate().getTime());
        } catch (NullPointerException ex) {
            fallo = true;
        }

        if (!fallo) {
            fechaNac.setTime(txtFechaNacimiento.getDate().getTime());
        }

        if (valido && valido2) {

            if (nuevoCliente) {

                resultado = consultaClientes.agregarNuevoCliente(txtNombre.getText(),
                        txtDireccion.getText(), txtColonia.getText(), fechaNac,
                        cboCivil.getSelectedItem().toString(), txtTelCasa.getText(),
                        txtTelCelular.getText(), txtTelTrabajo.getText(), txtCorreo.getText(),
                        txtCURP.getText(), cboEstatus.getSelectedItem().toString(),
                        txtLugarTrabajo.getText(), fallo);

                mensaje = "Se agregó nuevo cliente";

                idUltimoRegistroCliente = consultaClientes.obtenerIdUltimoRegistro();
                System.out.println(idUltimoRegistroCliente);

                resultado2 = consultaDatosFinancieros.agregaDatosFinancieros(idUltimoRegistroCliente,
                        txtBanco.getText(), txtNSS.getText(), txtFovisste.getText(),
                        Double.parseDouble(txtPresupuesto.getText()),
                        Double.parseDouble(txtAlcance.getText()));

            } else {

                resultado = consultaClientes.actualizarCliente(txtNombre.getText(),
                        txtDireccion.getText(), txtColonia.getText(), fechaNac,
                        cboCivil.getSelectedItem().toString(), txtTelCasa.getText(),
                        txtTelCelular.getText(), txtTelTrabajo.getText(), txtCorreo.getText(),
                        txtCURP.getText(), cboEstatus.getSelectedItem().toString(),
                        txtLugarTrabajo.getText(), idCliente, fallo);

                resultado2 = consultaDatosFinancieros.actualizaDatosFinancieros(idCliente,
                        txtBanco.getText(), txtNSS.getText(), txtFovisste.getText(),
                        Double.parseDouble(txtPresupuesto.getText()),
                        Double.parseDouble(txtAlcance.getText()), idDatosFinancieros);

                mensaje = "Cliente actualizado";
            }

            if (resultado == 1 && resultado2 == 1) {
                JOptionPane.showMessageDialog(null, mensaje,
                        "Clientes", JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "No se pudo realizar la operación",
                        "Clientes", JOptionPane.ERROR_MESSAGE);
            }

        } else {
            JOptionPane.showMessageDialog(null, "Escribe una cantidad valida en "
                    + "'Ingreso promedio'",
                    "Clientes", JOptionPane.ERROR_MESSAGE);
        }

        nuevoCliente = false;
        explorarClientes();
        explorarDatosFinancieros();

        cmdNuevo.setEnabled(true);
        cmdEliminar.setEnabled(true);

    }//GEN-LAST:event_cmdGuardarActionPerformed

    private void cboCivilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboCivilActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboCivilActionPerformed

    private void txtTelTrabajoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelTrabajoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTelTrabajoActionPerformed

    private void txtTelCasaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelCasaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTelCasaActionPerformed

    private void txtNombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNombreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNombreActionPerformed

    private void txtNSSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNSSActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNSSActionPerformed

    private void cmdNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNuevoActionPerformed
        nuevoCliente = true;
        cmdGuardar.setEnabled(true);
        cmdCancelar.setEnabled(true);
        cmdEliminar.setEnabled(false);

        txtNombre.setText("");
        txtDireccion.setText("");
        txtColonia.setText("");
        txtTelCasa.setText("");
        txtTelCelular.setText("");
        txtTelTrabajo.setText("");
        cboCivil.setSelectedIndex(0);
        txtCURP.setText("");
        txtCorreo.setText("");
        txtFechaNacimiento.setDate(null);
        txtLugarTrabajo.setText("");

        txtNSS.setText("");
        txtBanco.setText("");
        txtFovisste.setText("");
        txtPresupuesto.setText("0");
        txtAlcance.setText("0");
    }//GEN-LAST:event_cmdNuevoActionPerformed

    private void cmdPrimeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdPrimeroActionPerformed
        indiceActual = 0;
        txtIndiceActual.setText("" + (indiceActual + 1));
        txtIndiceActualActionPerformed(evt);
    }//GEN-LAST:event_cmdPrimeroActionPerformed

    private void cmdAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAnteriorActionPerformed
        indiceActual--;

        if (indiceActual < 0) {
            indiceActual = numeroClientes - 1;
        }

        txtIndiceActual.setText("" + (indiceActual + 1));
        txtIndiceActualActionPerformed(evt);
    }//GEN-LAST:event_cmdAnteriorActionPerformed

    private void cmdSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdSiguienteActionPerformed
        indiceActual++;

        if (indiceActual >= numeroClientes) {
            indiceActual = 0;
        }

        txtIndiceActual.setText("" + (indiceActual + 1));
        txtIndiceActualActionPerformed(evt);
    }//GEN-LAST:event_cmdSiguienteActionPerformed

    private void cmdUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdUltimoActionPerformed
        indiceActual = numeroClientes - 1;

        txtIndiceActual.setText("" + (indiceActual + 1));

        txtIndiceActualActionPerformed(evt);
    }//GEN-LAST:event_cmdUltimoActionPerformed

    private void txtIndiceActualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtIndiceActualActionPerformed

        String str = txtIndiceActual.getText();

        if (ValidaNumeros.validarNumeroEntero(str)) {

            indiceActual = (Integer.parseInt(str) - 1);

            indiceActualDatos = (Integer.parseInt(str) - 1);

            if (numeroClientes != 0 && indiceActual < numeroClientes
                    && numeroDatosFinancieros != 0 && indiceActualDatos < numeroDatosFinancieros) {

                clienteActual = resultadosClientes.get(indiceActual);
                idCliente = clienteActual.obtenerIdCliente();

                txtNombre.setText(clienteActual.obtenerNombre());
                txtDireccion.setText(clienteActual.obtenerCalle());
                txtColonia.setText(clienteActual.obtenerColonia());
                txtTelCasa.setText(clienteActual.obtenerTelefonoCasa());
                txtTelCelular.setText(clienteActual.obtenerTelefonoCelular());
                txtTelTrabajo.setText(clienteActual.obtenerTelefonoTrabajo());
                cboCivil.setSelectedItem(clienteActual.obtenerSoltero());
                txtCURP.setText(clienteActual.obtenerCURP());
                txtCorreo.setText(clienteActual.obtenerEMail());
                txtFechaNacimiento.setDate(clienteActual.obtenerFechaNacimiento());
                txtLugarTrabajo.setText(clienteActual.obtenerLugarTrabajo());
                cboEstatus.setSelectedItem(clienteActual.obtenerEstatus());

                datosFinancierosActual = resultadosDatosFinancieros.get(indiceActualDatos);

                idDatosFinancieros = datosFinancierosActual.obtenerIdDatosFinancieros();
                txtNSS.setText(datosFinancierosActual.obtenerNumeroSeguroSocial());
                txtBanco.setText(datosFinancierosActual.obtenerNumeroBanco());
                txtFovisste.setText(datosFinancierosActual.obtenerNumeroFovisste());
                txtPresupuesto.setText(String.valueOf(datosFinancierosActual.obtenerPresupuesto()));
                txtAlcance.setText(String.valueOf(datosFinancierosActual.obtenerAlcance()));

            }

        } else {
            JOptionPane.showMessageDialog(null, "Ingresa un número válido",
                    "Clientes", JOptionPane.ERROR_MESSAGE);
            explorarClientes();
            explorarDatosFinancieros();
        }
    }//GEN-LAST:event_txtIndiceActualActionPerformed

    private void cmdEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEliminarActionPerformed
        int resultado = 0;
        int resultado2 = 0;

        int opc = JOptionPane.showConfirmDialog(this, "¿Seguro que deseas eliminar este cliente?",
                "Clientes", JOptionPane.YES_NO_OPTION);

        if (opc == JOptionPane.YES_OPTION) {

            resultado2 = consultaDatosFinancieros.eliminarDatosFinancieros(idDatosFinancieros);
            resultado = consultaClientes.eliminarCliente(idCliente);

            if (resultado != 0 && resultado2 != 0) {

                JOptionPane.showMessageDialog(null, "Cliente eliminado",
                        "Clientes", JOptionPane.INFORMATION_MESSAGE);

                explorarClientes();
                explorarDatosFinancieros();

            } else {
                JOptionPane.showMessageDialog(null, "No se pudo eliminar cliente",
                        "Clientes", JOptionPane.INFORMATION_MESSAGE);
            }
        }

        cmdNuevo.setEnabled(true);
        cmdGuardar.setEnabled(true);
        cmdCancelar.setEnabled(true);
        cmdEliminar.setEnabled(true);
    }//GEN-LAST:event_cmdEliminarActionPerformed

    private void cmdCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCancelarActionPerformed
        explorarClientes();
        explorarDatosFinancieros();
        nuevoCliente = false;

        cmdNuevo.setEnabled(true);
        cmdGuardar.setEnabled(true);
        cmdCancelar.setEnabled(true);
        cmdEliminar.setEnabled(true);
    }//GEN-LAST:event_cmdCancelarActionPerformed

    private void cmdBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdBuscarActionPerformed

        javax.swing.ButtonGroup buttonGroup1 = new javax.swing.ButtonGroup();
        javax.swing.JRadioButton optNombre = new javax.swing.JRadioButton("Nombre", true);
        javax.swing.JRadioButton optCelular = new javax.swing.JRadioButton("Tel. Celular", false);
        javax.swing.JRadioButton optEMail = new javax.swing.JRadioButton("EMail", false);

        buttonGroup1.add(optNombre);
        buttonGroup1.add(optCelular);
        buttonGroup1.add(optEMail);

        javax.swing.JTextField txtParametro = new javax.swing.JTextField();

        Object[] controles = {"Buscar por", optNombre, optEMail, optCelular, txtParametro};

        int sel = JOptionPane.showConfirmDialog(null, controles,
                "Buscar cliente", JOptionPane.OK_CANCEL_OPTION);

        if (sel == JOptionPane.OK_OPTION) {
            if (optNombre.isSelected()) {
                buscarClienteNombre(txtParametro.getText());
                buscarDatosFinancierosNombre(txtParametro.getText());
            } else if (optCelular.isSelected()) {
                buscarClienteCelular(txtParametro.getText());
                buscarDatosFinancierosCelular(txtParametro.getText());
            } else if (optEMail.isSelected()) {
                buscarClienteCorreo(txtParametro.getText());
                buscarDatosFinancierosCorreo(txtParametro.getText());
            }
        }
    }//GEN-LAST:event_cmdBuscarActionPerformed

    private void txtCURPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCURPActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtCURPActionPerformed

    private void cboEstatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboEstatusActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboEstatusActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane ScrollPane;
    private javax.swing.JComboBox cboCivil;
    private javax.swing.JComboBox cboEstatus;
    private javax.swing.JButton cmdAnterior;
    private javax.swing.JButton cmdBuscar;
    private javax.swing.JButton cmdCancelar;
    private javax.swing.JButton cmdEliminar;
    private javax.swing.JButton cmdGuardar;
    private javax.swing.JButton cmdNuevo;
    private javax.swing.JButton cmdPrimero;
    private javax.swing.JButton cmdSiguiente;
    private javax.swing.JButton cmdUltimo;
    private com.toedter.calendar.JCalendar jCalendar1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblBanco;
    private javax.swing.JLabel lblCURP;
    private javax.swing.JLabel lblColonia;
    private javax.swing.JLabel lblCorreo;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblEdoCivil;
    private javax.swing.JLabel lblEstatus;
    private javax.swing.JLabel lblFechaNacimiento;
    private javax.swing.JLabel lblFovisste;
    private javax.swing.JLabel lblIngresoPromedio;
    private javax.swing.JLabel lblIngresoPromedio1;
    private javax.swing.JLabel lblLugarTrabajo;
    private javax.swing.JLabel lblNSS;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblSimbolo;
    private javax.swing.JLabel lblSimbolo1;
    private javax.swing.JLabel lblTelCasa;
    private javax.swing.JLabel lblTelCelular;
    private javax.swing.JLabel lblTelTrabajo;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JPanel txt;
    private javax.swing.JTextField txtAlcance;
    private javax.swing.JTextField txtBanco;
    private javax.swing.JTextField txtCURP;
    private javax.swing.JTextField txtColonia;
    private javax.swing.JTextField txtCorreo;
    private javax.swing.JTextField txtDireccion;
    private com.toedter.calendar.JDateChooser txtFechaNacimiento;
    private javax.swing.JTextField txtFovisste;
    private javax.swing.JTextField txtIndiceActual;
    private javax.swing.JTextArea txtLugarTrabajo;
    private javax.swing.JTextField txtNSS;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPresupuesto;
    private javax.swing.JTextField txtTelCasa;
    private javax.swing.JTextField txtTelCelular;
    private javax.swing.JTextField txtTelTrabajo;
    // End of variables declaration//GEN-END:variables

    private void buscarClienteNombre(String nombre) {
        resultadosClientes = consultaClientes.obtenerClienteNombre(nombre);
        numeroClientes = resultadosClientes.size();

        if (numeroClientes != 0) {
            indiceActual = 0;
            clienteActual = resultadosClientes.get(indiceActual);

            idCliente = clienteActual.obtenerIdCliente();
            txtNombre.setText(clienteActual.obtenerNombre());
            txtDireccion.setText(clienteActual.obtenerCalle());
            txtColonia.setText(clienteActual.obtenerColonia());
            txtTelCasa.setText(clienteActual.obtenerTelefonoCasa());
            txtTelCelular.setText(clienteActual.obtenerTelefonoCelular());
            txtTelTrabajo.setText(clienteActual.obtenerTelefonoTrabajo());
            cboCivil.setSelectedItem(clienteActual.obtenerSoltero());
            txtCURP.setText(clienteActual.obtenerCURP());
            txtCorreo.setText(clienteActual.obtenerEMail());
            txtFechaNacimiento.setDate(clienteActual.obtenerFechaNacimiento());
            txtLugarTrabajo.setText(clienteActual.obtenerLugarTrabajo());
            cboEstatus.setSelectedItem(clienteActual.obtenerEstatus());

            txtIndiceActual.setText("" + (indiceActual + 1));
            lblTotal.setText("" + numeroClientes);

        }
    }

    private void buscarClienteCelular(String telCelular) {
        resultadosClientes = consultaClientes.obtenerClienteCelular(telCelular);
        numeroClientes = resultadosClientes.size();

        if (numeroClientes != 0) {
            indiceActual = 0;
            clienteActual = resultadosClientes.get(indiceActual);

            idCliente = clienteActual.obtenerIdCliente();
            txtNombre.setText(clienteActual.obtenerNombre());
            txtDireccion.setText(clienteActual.obtenerCalle());
            txtColonia.setText(clienteActual.obtenerColonia());
            txtTelCasa.setText(clienteActual.obtenerTelefonoCasa());
            txtTelCelular.setText(clienteActual.obtenerTelefonoCelular());
            txtTelTrabajo.setText(clienteActual.obtenerTelefonoTrabajo());
            cboCivil.setSelectedItem(clienteActual.obtenerSoltero());
            txtCURP.setText(clienteActual.obtenerCURP());
            txtCorreo.setText(clienteActual.obtenerEMail());
            txtFechaNacimiento.setDate(clienteActual.obtenerFechaNacimiento());
            txtLugarTrabajo.setText(clienteActual.obtenerLugarTrabajo());
            cboEstatus.setSelectedItem(clienteActual.obtenerEstatus());

            txtIndiceActual.setText("" + (indiceActual + 1));
            lblTotal.setText("" + numeroClientes);
        }
    }

    private void buscarClienteCorreo(String correo) {
        resultadosClientes = consultaClientes.obtenerClienteEMail(correo);
        numeroClientes = resultadosClientes.size();

        if (numeroClientes != 0) {
            indiceActual = 0;
            clienteActual = resultadosClientes.get(indiceActual);

            idCliente = clienteActual.obtenerIdCliente();
            txtNombre.setText(clienteActual.obtenerNombre());
            txtDireccion.setText(clienteActual.obtenerCalle());
            txtColonia.setText(clienteActual.obtenerColonia());
            txtTelCasa.setText(clienteActual.obtenerTelefonoCasa());
            txtTelCelular.setText(clienteActual.obtenerTelefonoCelular());
            txtTelTrabajo.setText(clienteActual.obtenerTelefonoTrabajo());
            cboCivil.setSelectedItem(clienteActual.obtenerSoltero());
            txtCURP.setText(clienteActual.obtenerCURP());
            txtCorreo.setText(clienteActual.obtenerEMail());
            txtFechaNacimiento.setDate(clienteActual.obtenerFechaNacimiento());
            txtLugarTrabajo.setText(clienteActual.obtenerLugarTrabajo());
            cboEstatus.setSelectedItem(clienteActual.obtenerEstatus());

            txtIndiceActual.setText("" + (indiceActual + 1));
            lblTotal.setText("" + numeroClientes);
        }
    }

    private void buscarDatosFinancierosNombre(String nombre) {
        resultadosDatosFinancieros = consultaDatosFinancieros.obtenerDatosFinancierosNombre(nombre);
        numeroDatosFinancieros = resultadosDatosFinancieros.size();

        if (numeroDatosFinancieros != 0) {
            indiceActualDatos = 0;
            datosFinancierosActual = resultadosDatosFinancieros.get(indiceActualDatos);

            idDatosFinancieros = datosFinancierosActual.obtenerIdCliente();
            txtNSS.setText(datosFinancierosActual.obtenerNumeroSeguroSocial());
            txtBanco.setText(datosFinancierosActual.obtenerNumeroBanco());
            txtFovisste.setText(datosFinancierosActual.obtenerNumeroFovisste());
            txtPresupuesto.setText(String.valueOf(datosFinancierosActual.obtenerPresupuesto()));
            txtAlcance.setText(String.valueOf(datosFinancierosActual.obtenerAlcance()));

        } else {
            JOptionPane.showMessageDialog(null, "No se encontraron resultados",
                    "Búsqueda", JOptionPane.INFORMATION_MESSAGE);
            cmdCancelarActionPerformed(null);
        }
    }

    private void buscarDatosFinancierosCelular(String celular) {
        resultadosDatosFinancieros = consultaDatosFinancieros.obtenerDatosFinancierosCelular(celular);
        numeroDatosFinancieros = resultadosDatosFinancieros.size();

        if (numeroDatosFinancieros != 0) {
            indiceActualDatos = 0;
            datosFinancierosActual = resultadosDatosFinancieros.get(indiceActualDatos);

            idDatosFinancieros = datosFinancierosActual.obtenerIdCliente();
            txtNSS.setText(datosFinancierosActual.obtenerNumeroSeguroSocial());
            txtBanco.setText(datosFinancierosActual.obtenerNumeroBanco());
            txtFovisste.setText(datosFinancierosActual.obtenerNumeroFovisste());
            txtPresupuesto.setText(String.valueOf(datosFinancierosActual.obtenerPresupuesto()));
            txtAlcance.setText(String.valueOf(datosFinancierosActual.obtenerAlcance()));

        } else {
            JOptionPane.showMessageDialog(null, "No se encontraron resultados",
                    "Búsqueda", JOptionPane.INFORMATION_MESSAGE);
            cmdCancelarActionPerformed(null);
        }
    }

    private void buscarDatosFinancierosCorreo(String correo) {
        resultadosDatosFinancieros = consultaDatosFinancieros.obtenerDatosFinancierosEMail(correo);
        numeroDatosFinancieros = resultadosDatosFinancieros.size();

        if (numeroDatosFinancieros != 0) {
            indiceActualDatos = 0;
            datosFinancierosActual = resultadosDatosFinancieros.get(indiceActualDatos);

            idDatosFinancieros = datosFinancierosActual.obtenerIdCliente();
            txtNSS.setText(datosFinancierosActual.obtenerNumeroSeguroSocial());
            txtBanco.setText(datosFinancierosActual.obtenerNumeroBanco());
            txtFovisste.setText(datosFinancierosActual.obtenerNumeroFovisste());
            txtPresupuesto.setText(String.valueOf(datosFinancierosActual.obtenerPresupuesto()));
            txtAlcance.setText(String.valueOf(datosFinancierosActual.obtenerAlcance()));

        } else {
            JOptionPane.showMessageDialog(null, "No se encontraron resultados",
                    "Búsqueda", JOptionPane.INFORMATION_MESSAGE);
            cmdCancelarActionPerformed(null);
        }
    }
}
